from requests import Response


def assert_response(response: Response, param: dict):
    # 响应中响应行内的http状态码
    actual_status_code = response.status_code
    # 响应body中的返回码/响应码-开发自定义
    actual_status = response.json()['status']
    # 响应body中接口返回信息msg
    actual_msg = response.json()['msg']
    # 实际的body
    actual_body = response.text

    assert actual_status_code == param['status_code'], \
        f"响应行中状态码和预期不符: 预期({param['status_code']})实际({actual_status_code})"
    assert actual_status == param['status'], \
        f"响应体中相应码和预期不符: 预期({param['status']})实际({actual_status})"
    assert actual_msg == param['msg'], \
        f"响应体中msg和预期不符: 预期({param['msg']})实际({actual_msg})"
    assert actual_body.__contains__(param['contains']), \
        f"响应体中不含预期数据: 预期数据({param['contains']})响应体({actual_body})"
